import React, { Component } from 'react';
import { connect } from 'react-redux';
import ACTIONS from '../../../redux/action';
// 定义一个名为operationButton的组件，继承自Component
class operationButton extends Component {
    // 初始化state
    state = {  } 
    // 渲染组件
    render() { 
        // 返回一个button元素，点击时调用props中的chooseOperation方法，并传入props中的operation参数
        return (
            <button onClick={() => {
                this.props.chooseOperation(this.props.operation)
            }}>
                {this.props.operation}
            </button>
        );
    }
}

const mapDispatchToProps = {
    chooseOperation: operation => {
        return {
            type: ACTIONS.CHOOSE_OPERATION,
            operation: operation,
        }
    },

}
 
export default connect(null, mapDispatchToProps)(operationButton);